<template>
  <div>
    <base-page ref="basePage" :basepage="basePage"></base-page>
  </div>
</template>
<script>
import BasePage from "../BasePage.vue";
export default {
  components: {
    "base-page": BasePage,
  },
  data() {
    return {
      basePage: {
        // URL
        url: "pressOperation",
        // 查询条件
        searchConf: [
          [
            {
              title: "出版社名称",
              type: "input",
              prop: "pressName",
            },
            {
              title: "出版社电话",
              type: "input",
              prop: "phone",
            },
            {
              title: "出版社地址",
              type: "input",
              prop: "address",
            },
            {
              title: "是否有效",
              type: "select",
              prop: "available",
              data: [
                { value: "1", label: "有效" },
                { value: "0", label: "无效" },
              ],
            },
          ],
        ],
        buttonConf: {
          insertShow: true,
          deleteShow: true,
        },
        // table列
        tableColumnConf: {
          columns: [
            { prop: "pressName", label: "出版社名称" },
            { prop: "phone", label: "出版社电话" },
            { prop: "address", label: "出版社地址" },
            { prop: "createName", label: "创建人" },
            { prop: "createTime", label: "创建时间" },
            { prop: "available", label: "是否有效" },
          ],
          operation: {
            state: true,
            defs: [],
          },
        },
        detailConf: {
          title: "出版社信息",
          data: [],
        },
        // 新增修改form表单设置
        formConf: {
          formData: {
            pressName: "",
            phone: "",
            address: "",
            available: "",
          },
          width: "50%",
          title: "",
          data: [
            {
              title: "出版社名称",
              type: "input",
              prop: "pressName",
            },
            {
              title: "出版社电话",
              type: "input",
              prop: "phone",
            },
            {
              title: "出版社地址",
              type: "input",
              prop: "address",
            },
            {
              title: "是否有效",
              type: "select",
              prop: "available",
              data: [
                { value: "1", label: "有效" },
                { value: "0", label: "无效" },
              ],
            },
          ],
          rules: {
            pressName: [
              {
                validator: (rule, value, callback) => {
                  if (value === "") {
                    callback(new Error("名称不能为空"));
                  } else {
                    callback();
                  }
                },
                trigger: "blur",
              },
            ],
            phone: [
              {
                validator: (rule, value, callback) => {
                  if (value === "") {
                    callback(new Error("电话不能为空"));
                  } else {
                    callback();
                  }
                },
                trigger: "blur",
              },
            ],
            address: [
              {
                validator: (rule, value, callback) => {
                  if (value === "") {
                    callback(new Error("地址不能为空"));
                  } else {
                    callback();
                  }
                },
                trigger: "blur",
              },
            ],
            available: [
              {
                validator: (rule, value, callback) => {
                  if (value === "") {
                    callback(new Error("状态不能为空"));
                  } else {
                    callback();
                  }
                },
                trigger: "blur",
              },
            ],
          },
        },
      },
    };
  },
  methods: {
    event(event) {
      switch (event) {
      }
    },
    selectChange(type, pro, value) {},
    formatter(data, prop, index) {
      switch (prop) {
        case "available": {
          if (data == "1") {
            return "有效";
          } else {
            return "无效";
          }
        }
        default: {
          return data;
        }
      }
    },
  },
  activated: function () {},
};
</script>
<style>
</style>